package cn.gok.server.service.impl;

import cn.gok.common.dao.customer.CustomerLevelInfoDao;
import cn.gok.common.entity.customer.CustomerLevelInfo;
import cn.gok.server.service.CustomerLevelInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: DxlinY
 * @apiNote: 用户等级信息维护服务类
 * @date: 2020/11/11
 * @time: 14:24
 */
@Service
@Slf4j
public class CustomerLevelInfoServiceImpl implements CustomerLevelInfoService {
    @Autowired
    private CustomerLevelInfoDao customerLevelInfoDao;

    @Override
    public PageInfo pageInfo(Object target) {
        QueryWrapper <CustomerLevelInfo> wrapper = new QueryWrapper <>();
        wrapper.setEntity((CustomerLevelInfo) target);
        return new PageInfo(customerLevelInfoDao.selectList(wrapper));
    }

    @Override
    public int insertCustomerLevelInfo(CustomerLevelInfo customerLevelInfo) {
        log.info("新增一个会员等级信息{}", customerLevelInfo);
        return customerLevelInfoDao.insert(customerLevelInfo);
    }

    @Override
    public int delByIds(List <Integer> ids) {
        log.info("批量删除会员等级信息");
        return customerLevelInfoDao.deleteBatchIds(ids);
    }

    @Override
    public int updateById(CustomerLevelInfo customerLevelInfo) {
        log.info("修改会员等级信息{}", customerLevelInfo);
        return customerLevelInfoDao.updateById(customerLevelInfo);
    }

    @Override
    public CustomerLevelInfo getById(Integer id) {
        log.info("通过id获取用户等级信息{}", id);
        return customerLevelInfoDao.selectById(id);
    }
}
